Algorithms

Sequence and Selection

Sequence

A sequence is the simplest type of algorithm. Sequences are made up of a set of instructions that must be carried out in order, one at a time. An example of a sequence is an algorithm that takes 2 numbers, adds them together and outputs the result. Watch the example shown in the animation below:




Selection

There is only one possible path through a sequential algorithm; however, algorithms that use selection have two or more possible paths through them. The path that is taken depends on whether the answer to a question is 'Yes' or 'No'.

The algorithm in the example flowchart shown below asks the user to input their age; if they are 15 or over it outputs "You can watch the movie" otherwise it outputs "You are too young to watch this movie".